<template>
	<div id="app">
		<!-- <Header></Header> -->
		<router-view />
		<!-- <Footer v-if="$route.meta.isFootShow"></Footer> -->
	</div>
</template>
<script>
	// import Footer from "./components/footer";
	// import Header from "./components/header";
	import { Toast } from "vant";
	export default {
		data() {
			return {
				// footer_show: true
				userinfo: {},
				is_ios: false,
			};
		},
		components: {
			// Footer,
			// Header,
		},
		mounted() {
			this.getType()	
		},
		created() {
			var token = this.$route.query.token;
			if(token){
				this.$store.commit('SAVE_TOKEN',token)
			}
			this.getUrlData();
			localStorage.setItem('user', JSON.stringify(this.userinfo));
		},
		methods: {
			//是否显示底部
			// footer: function(bool) {
			//   this.footer_show = bool;
			// }
			getUrlData() {
				/**
				 * tempStr 格式是http://域名/路由?key=value&key=value...
				 */
				let tempStr = window.location.href
				console.log(tempStr)
				/**
				 * tempArr 是一个字符串数组 格式是["key=value", "key=value", ...]
				 */
				let tempArr = tempStr.split('?')[1] ? tempStr.split('?')[1].split('&') : []
				/**
				 * returnArr 是要返回出去的数据对象 格式是 { key: value, key: value, ... }
				 */
				let returnArr = {}
				tempArr.forEach(element => {
					returnArr[element.split('=')[0]] = element.split('=')[1]
				})
				/*输出日志*/
				this.userinfo = returnArr;
				// console.log(this.userinfo);
				return this.userinfo;
			},
			getType(){
				const userAgent = navigator.userAgent;
				if (/bAndroidb/i.test(userAgent)) {
					this.$store.commit('SAVE_IOS',false);
					return 'Android';
				} else if (
					/iphone/gi.test(navigator.userAgent) ||
					/biOSb/i.test(userAgent)
				) {
					this.$store.commit('SAVE_IOS',true);
					return 'IOS';
				}
			}
		},
	};
</script>
<style lang="scss">
	html,
	body,
	p,
	div,
	h2,
	h3,
	h4,
	img,
	span {
		margin: 0;
		padding: 0;
	}

	html,
	body,
	#app {
		height: 100%;
	}

	#nav {
		padding: 30px;

		a {
			font-weight: bold;
			color: #2c3e50;

			&.router-link-exact-active {
				color: #42b983;
			}
		}
	}
	.page1 {
		background-color: #fff;
		min-height: 100vh;
		}
	.page {
		background: #f7f7f7;
		// background-color: #fff;
		min-height: 100vh;
	}
	.fade-enter,
	.fade-leave-active {
		opacity: 0;
	}

	.fade-enter-active,
	.fade-leave-active {
		transition: opacity 0.5s;
	}

	.fade-enter,
	.fade-leave-active {
		opacity: 0;
	}

	.fade-enter-active,
	.fade-leave-active {
		transition: opacity 0.5s;
	}
</style>

